layui.define(["jquery", "layer", "form"], function(t) {
	var e = layui.jquery,
		c = layui.form,
		s = layui.layer,
		l = layui.device(),
		a = (function() {
			var v = ".slider-item{height:38px;line-height:38px;background-color:#d0d0d0;position:relative;border: 1px solid white;}.slider-bg{position:absolute;width:40px;height:100%;z-index:100}.slider-btn{width:40px;height:94%;position:absolute;border:1px solid #ccc;cursor:move;text-align:center;background-color:#fff;user-select:none;color:#666;z-index:120}.slider-btn-success{font-size:26px}.slider-text{position:absolute;text-align:center;width:100%;height:100%;user-select:none;font-size:14px;color:#fff;z-index:120;border-radius: 2px;}.slider-error{animation:glow 800ms ease-out infinite alternate;}@keyframes glow{0%{border-color:#e6e6e6}100%{border-color:#ff5722}}",
				w = document.createElement("style");
			w.innerHTML = v;
			w.type = "text/css";
			(e("head link:last")[0] && e("head link:last")
				.after(w)) || e("head")
				.append(w)
		})(),
		i = {
			version: "1.7.2"
		},
		n = function(v) {
			return v[0]
		},
		p = function() {
			var v = this;
			return {
				isOk: function() {
					return v.isOk.call(v)
				},
				reset: function() {
					return v.reset.call(v)
				}
			}
		},
		h = "sliderVerify",
		j = "slider-btn",
		k = "slider-bg",
		r = "slider-text",
		b = "layui-icon-next",
		u = "layui-icon-ok-circle",
		g = "slider-btn-success",
		o = "layui-bg-green",
		d = "slider-error",
		q = "请拖动滑块验证",
		f = "验证通过",
		m = function(v) {
			var w = this;
			w.config = e.extend({}, w.config, v);
			w.render()
		};
	m.prototype.config = {
		elem: "",
		onOk: null,
		isOk: false,
		isAutoVerify: true,
		timer: null,
		bg: o,
		text: q
	};
	m.prototype.render = function() {
		var x = this,
			v = x.config,
			w = e(v.elem);
		if (!w[0]) {
			return
		}
		if (v.domid) {
			v.domid.remove()
		}
		v.domid = x.createIdNum();
		var y = e(['<div id="' + v.domid + '"' + (v.isAutoVerify ? 'lay-verify="sliderVerify"' : "") + 'class="slider-item">', '<div class="' + k + " " + v.bg + '"></div>', '<div class="' + r + '">' + v.text + "</div>", '<div class="' + j + ' layui-icon layui-icon-next"></div>'].join(""));
		w.hide()
			.after(y);
		v.domid = e("#" + v.domid);
		x.events();
		if (v.isAutoVerify) {
			c.verify({
				sliderVerify: function(z, A) {
					if (!z) {
						A.classList.add(d);
						return v.text
					}
				}
			})
		}
	};
	m.prototype.isMobile = function() {
		return (l.os == "ios" || l.os == "android" || l.android || l.ios || (l.weixin && typeof l.weixin === Boolean))
	};
	m.prototype.createIdNum = function() {
		return (h + (+new Date())
			.toString() + Math.random()
			.toString()
			.substr(2, 7))
	};
	m.prototype.isOk = function() {
		return this.config.isOk
	};
	m.prototype.error = function(v) {
		return s.msg(v, {
			icon: 5
		})
	};
	m.prototype.distance = function() {
		var v = this.config.container;
		return v.box.offsetWidth - v.btn.offsetWidth
	};
	m.prototype.reset = function() {
		this.config.isOk = false;
		return this.render()
	};
	m.prototype.resize = function(x) {
		var w = this,
			v = w.config.container;
		var x = x || w.distance();
		v.btn.style.left = x + "px";
		v.bg.style.width = x + "px"
	};
	m.prototype.cancelTransition = function() {
		var v = this.config.container;
		this.config.domid[0].classList.remove(d);
		v.btn.style.transition = "";
		v.bg.style.transition = ""
	};
	m.prototype.down = function(z) {
		var y = this,
			x = y.config,
			w = x.container,
			z = z || window.event,
			A = z.clientX || z.touches[0].clientX;
		y.cancelTransition();
		var v = function(B) {
			y.move(A, B)
		};
		y.events.move = v;
		if (y.isMobile()) {
			document.addEventListener("touchmove", y.events.move)
		} else {
			document.onmousemove = v
		}
		if (navigator.userAgent.indexOf("UCBrowser") > -1) {
			z.preventDefault()
		}
	};
	m.prototype.move = function(D, C) {
		var B = this,
			z = B.config,
			v = z.container;
		var C = C || window.event;
		var x = C.clientX || C.touches[0].clientX;
		var A = x - D;
		if (A > v.distance) {
			A = v.distance
		} else {
			if (A < 0) {
				A = 0
			}
		}
		v.btn.style.left = A + "px";
		v.bg.style.width = A + "px";
		if (A == v.distance) {
			v.text.innerHTML = f;
			var w = window.getComputedStyle ? window.getComputedStyle(v.bg, null) : v.bg.currentStyle;
			v.btn.style.border = "1px solid " + w.backgroundColor;
			v.btn.style.color = w.backgroundColor;
			v.btn.classList.remove(b);
			v.btn.classList.add(u, g);
			z.isOk = true;
			v.box.value = true;
			if (B.isMobile()) {
				v.btn.removeEventListener("touchstart", B.events.down, false);
				document.removeEventListener("touchmove", B.events.move, false)
			} else {
				v.btn.onmousedown = null;
				document.onmousemove = null
			}
			z.onOk && typeof z.onOk == "function" && z.onOk();
			return
		}
		var y = function(E) {
			B.stop(E)
		};
		B.events.seup = y;
		if (B.isMobile()) {
			document.addEventListener("touchend", y)
		} else {
			document.onmouseup = y
		}
	};
	m.prototype.stop = function(y) {
		var x = this,
			w = x.config,
			v = w.container;
		if (x.isOk()) {
			return
		} else {
			v.btn.style.left = 0;
			v.bg.style.width = 0;
			v.btn.style.transition = "left 1s";
			v.bg.style.transition = "width 1s"
		}
		document.onmousemove = null;
		document.onmouseup = null;
		if (x.isMobile()) {
			document.removeEventListener("touchmove", x.events.move, false);
			document.removeEventListener("touchend", x.events.seup, false)
		}
	};
	m.prototype.events = function() {
		var A = this,
			z = A.config;
		if (!z.domid) {
			return A.error("创建滑块验证失败")
		}
		var y = z.domid.find("." + j),
			x = z.domid.find("." + k),
			B = z.domid.find("." + r),
			w = {
				box: n(z.domid),
				btn: n(y),
				bg: n(x),
				text: n(B)
			};
		z.container = w;
		w.distance = A.distance();
		var C = function(D) {
			A.down(D)
		};
		A.events.down = C;
		if (A.isMobile()) {
			w.btn.addEventListener("touchstart", A.events.down)
		} else {
			w.btn.onmousedown = C
		}
		var v = e(window);
		v.on("resize", z.domid, function() {
			if (A.config.isOk) {
				A.resize()
			} else {
				clearTimeout(z.timer);
				z.timer = setTimeout(function() {
					A.render()
				}, 400)
			}
		})
	};
	i.render = function(v) {
		var w = new m(v);
		return p.call(w)
	};
	t(h, i)
});